package com.edu.study.base.rest;

import com.edu.base.common.utils.DateUtils;
import com.edu.base.ums.collectRecord.domain.ClsMemberCollectRecord;
import com.edu.base.ums.collectRecord.service.IClsMemberCollectRecordService;
import com.edu.study.base.StuCommonClassifyCatalog.service.IStuCommonClassifyCatalogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.UUIDUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *    提供我的记录  1.我的收藏   2.我的查询记录
     * @ClassName: AppRecordController
     * @Description: TODO(这里用一句话描述这个类的作用)
     * @author admin
     * @date 2021年7月21日
     *
 */
@Api(tags = "B、我的记录相关接口")
@RestController
@RequestMapping("/api/recored")
public class AppRecordController extends BaseController {
	
    @Autowired
    private IClsMemberCollectRecordService clsMemberCollectRecordService;
    
    @Autowired
    private IStuCommonClassifyCatalogService stuCommonClassifyCatalogService;
    
	/**
     * 查询会员收藏列表
     */ 
    @GetMapping("/list")
    @ApiOperation("查询我的收藏或我查看记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "会员Id",required = true),
            @ApiImplicitParam(name = "type", value = "类型 1：我收藏,2:我查看记录",required = true), 
       })
	public TableDataInfo list(String memberId, String type) { 
		startPage();
		ClsMemberCollectRecord clsMemberCollectRecord = new ClsMemberCollectRecord();
		clsMemberCollectRecord.setMemberId(memberId);
		clsMemberCollectRecord.setType(type);
		List<ClsMemberCollectRecord> list = clsMemberCollectRecordService.selectMemberRecordList(clsMemberCollectRecord);
		return getDataTable(list);
	}
     
     
    /**
     * 新增会员收藏和我看过的记录
     */
    @PostMapping("/add")
	@ApiOperation(value = "添加会员收藏信息或我看过的记录",response= ClsMemberCollectRecord.class)
    @ApiImplicitParams({
        @ApiImplicitParam(name = "memberId", value = "会员Id",required = true),
        @ApiImplicitParam(name = "courseId", value = "课程Id",required = true),
        @ApiImplicitParam(name = "type", value = "类型 1：我收藏,2:我查看记录",required = true),
   })
    public AjaxResult add(String memberId,String courseId,String type)
    {
    	ClsMemberCollectRecord vo  = new ClsMemberCollectRecord();
    	vo.setId(UUIDUtils.getUUID());
    	vo.setCreateTime(DateUtils.getNow());
    	vo.setMemberId(memberId);
    	vo.setCourseId(courseId);
    	//vo.setCourseIcon(courseIcon);
    	vo.setType(type);
        return toAjax(clsMemberCollectRecordService.insertClsMemberCollectRecord(vo));
    }
    
    /**
     * 删除会员收藏或我看过记录
     */ 
	@DeleteMapping("/{ids}")
    @ApiOperation("删除我的收藏或我查看记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "记录ids",required = true),
       })
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(clsMemberCollectRecordService.deleteClsMemberCollectRecordByIds(ids));
    }

}
